﻿using System;
using System.Collections.Generic;
using System.Text;

namespace PCR.Base
{
    /// <summary>
    /// Object access inteface
    /// </summary>
    /// <typeparam name="T">Object type</typeparam>
    public interface IObjectAccess<T>
    {
        /// <summary>
        /// Append a object
        /// </summary>
        /// <param name="item">Object instance to append</param>
        void Append(T item);

        /// <summary>
        /// Append a list of object
        /// </summary>
        /// <param name="items">Object list to append</param>
        void Append(IList<T> items);

        /// <summary>
        /// Update the object
        /// </summary>
        /// <param name="item">Object instance to update</param>
        void Update(T item);
        
        /// <summary>
        /// Update the object by ID
        /// </summary>
        /// <param name="id">Object ID</param>
        /// <param name="item">Object instance to update</param>
        void UpdateByID(Guid id, T item);
        
        /// <summary>
        /// Delete specified object
        /// </summary>
        /// <param name="item">Object instance to delete</param>
        void Delete(T item);

        /// <summary>
        /// Delete list of objects
        /// </summary>
        /// <param name="items">Objects to delete</param>
        void Delete(IList<T> items);

        /// <summary>
        /// Delete object by ID
        /// </summary>
        /// <param name="id">Object ID to delete</param>
        void DeleteByID(Guid id);

        /// <summary>
        /// Delete all objects
        /// </summary>
        void DeleteAll();

        /// <summary>
        /// Select all the objects
        /// </summary>
        /// <returns></returns>
        IList<T> SelectAll();

        /// <summary>
        /// Select object by ID
        /// </summary>
        /// <param name="id">Object ID to find</param>
        /// <returns>The found object instance</returns>
        T SelectByID(Guid id);

        /// <summary>
        /// Search the objects by specified filter 
        /// </summary>
        /// <param name="filter">The search filter</param>
        /// <returns>The found objects</returns>
        IList<T> Search(ISearchFilter<T> filter);
    }

    /// <summary>
    /// Standard curve access interface, 
    /// save and load all state and data of standard curves
    /// </summary>
    public interface IStdCurveAccess :  IObjectAccess<IStdCurve>
    {
        /// <summary>
        /// Save and load the active standard curve
        /// </summary>
        IStdCurve Active { get; set; }
    }

    /// <summary>
    /// User privilege interface, 
    /// save and load all user's information
    /// </summary>
    public interface IPrivilegeAccess
    {
        /// <summary>
        /// Get the user instance
        /// </summary>
        /// <returns>Return the current user interface</returns>
        IUser GetUser();
        
        /// <summary>
        /// Update the user information
        /// </summary>
        /// <param name="userName">User name</param>
        /// <param name="password">Password</param>
        bool UpdateUser(string userName, string password);
    }
    
    /// <summary>
    /// Virus type database interface, load or save all virus type datas
    /// </summary>
    public interface IVirusTypeAccess : IObjectAccess<IVirusType>
    {
        /// <summary>
        /// Get or set the base cell count, all the virus CT calculation
        /// will base on this same value
        /// </summary>
        UInt32 BaseCellCount { get; set; }

        /// <summary>
        /// Get or set the virus valve value
        /// if the virus Exponent > VirusSafetyExponent, it will be "阳性"
        /// else it will be "阴性"
        /// </summary>
        double VirusSafetyExponent { get; set; }
    }

    /// <summary>
    /// Configuration interface, load or save all configuration
    /// </summary>
    public interface IConfigAccess 
    {
        IPrintingSetting PrintingSetting { get; set; }
    }

    /// <summary>
    /// Database interface, defined all objects access
    /// </summary>
    public interface IDatabase
    {
        /// <summary>
        /// Get the standard curve object access interface
        /// </summary>
        IStdCurveAccess StdCurves { get; }

        /// <summary>
        /// Get the patient report interface
        /// </summary>
        IObjectAccess<IPatientReport> PatientReports { get; }

        /// <summary>
        /// Get the virus type interface
        /// </summary>
        IVirusTypeAccess VirusTypes { get; }
        
        /// <summary>
        /// Get the privilege interface
        /// </summary>
        IPrivilegeAccess Privilege { get; }

        /// <summary>
        /// Get the configuration interface
        /// </summary>
        IConfigAccess Config { get; }
    }

}
